﻿@model Zor_Web.Models.Base.V_Zor_TenantEnterprise
@using Webdiyer.WebControls.Mvc;
@{
    Layout = null;
}

<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>个人租户管理</title>
    <link href="~/Content/LayerUI/src/css/layui.css" rel="stylesheet" />
    <link href="~/Content/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
    <link href="~/Content/Styles/zor.css" rel="stylesheet" />
    <!-- 框架必要 -->
    <script src="~/Content/Scripts/jquery/jquery-1.9.1.min.js"></script>
    <script src="~/Content/Scripts/learunui-framework.js"></script>
    <script src="~/Content/Scripts/Zor_AJax.js"></script>
    <!-- 消息提示 -->
    <script language='javascript' src='~/Content/layer/layer.js'></script>
    <!-- 表单验证 -->
    <script src="~/Content/Scripts/JValidator.js"></script>
   
</head>
<body class="gray-bg">
    <div class="layui-tab layui-tab-brief main-tab-container ">

        <div class="col-sm-12 ct-padding">
            <div class="col-sm-9 ct-padding">
                <button id="btnAdd" class="layui-btn layui-btn layui-btn-small"><span class="glyphicon glyphicon-plus"></span> 新增</button>
                <button id="btnUpdate" class="layui-btn layui-btn-warm layui-btn-small"><span class="glyphicon glyphicon-pencil"></span> 编辑</button>
                <button id="btnDelete" class="layui-btn layui-btn-danger layui-btn-small"><span class="glyphicon glyphicon-trash"></span> 删除</button>                        
                <button id="btnSearchFull" class="layui-btn  layui-btn-normal layui-btn-small"><span class="glyphicon glyphicon-search"></span>查询</button>
                <button id="btnMessage" class="layui-btn layui-btn-orchid layui-btn-small"><span class="glyphicon glyphicon-list-alt"></span>详情</button>
                <button id="btnExport" class="layui-btn layui-btn-springgreen  layui-btn-small"><span class="glyphicon glyphicon-arrow-down"></span>导出</button>
                <button id="btnRefresh" class="layui-btn layui-btn-blue layui-btn-small"><span class="glyphicon glyphicon-repeat"></span>刷新</button>
            </div>
        </div>
        <div class="layui-tab-content">
            <table class="layui-table" lay-skin="line">
                <thead>
                    <tr>
                        <th hidden></th>
                        <th></th>
                        <th>姓名</th>
                        <th>性别</th>
                        <th>身份证</th>
                        <th>联系电话</th>
                        <th>工作单位</th>
                        <th>入租人数</th>
                        <th>人口性质</th>
                        <th>管理代码</th>
                    </tr>
                </thead>
                <tbody id="accordion">
                    @foreach (var item in Model.PageData)
                    {
                        <tr>
                            <td hidden>@item.Tenant_Id</td>
                            <td><input type="radio" name="chk" id="@item.Tenant_Id" value="@item.Tenant_Id" /></td>
                            <td>@item.Tenant_Name</td>
                            <td>@item.sex</td>
                            <td>@item.Tenant_IDNumber</td>
                            <td>@item.Tenant_Phone</td>
                            <td>@item.Tenant_Company</td>
                            <td>@item.Tenant_Number</td>
                            <td>@item.nature</td>
                            <td>@item.Tenant_Code</td>
                            <td hidden>@item.Tenant_Sex</td>
                            <td hidden>@item.Tenant_Nature</td>
                            <td hidden>@item.Tenant_Nationality</td>
                            <td hidden>@item.Tenant_IsTaxRegistration</td>
                            <td hidden>@item.Tenant_Vocation</td>
                            <td hidden>@item.nationality</td>
                            <td hidden>@item.vocation</td>

                        </tr>
                    }

                </tbody>
            </table>
            <div class="col-sm-12">
                <div class="col-sm-10">
                    @Html.Pager(Model.PageData, new PagerOptions { PageIndexParameterName = "index", ContainerTagName = "ul", PrevPageText = "上页", NextPageText = "下页", FirstPageText = "首页", LastPageText = "尾页", CssClass = "pagination", PagerItemsSeperator = "", CurrentPagerItemWrapperFormatString = "<li class=\"active\"><a href=\"#\">{0}</a></li>", PagerItemWrapperFormatString = "<li>{0}</li>" }, new { id = "bootstrappager", @class = "pagination" })
                </div>
                <div class="col-sm-2 to-righjt">
                    共 @Model.PageData.TotalItemCount 条记录，页 @Model.PageData.CurrentPageIndex/@Model.PageData.TotalPageCount
                </div>
            </div>
        </div>
    </div>

    <!-- 模态 -->
    <div id="myModal" hidden data-backdrop="static">
        <div id="divfrom" class="layui-tab-content">
            <form method="get" class="form-horizontal m-t">
                <div class="layui-form-item" hidden>
                    <label class="col-sm-3 layui-form-label">租户Id：</label>
                    <div class="col-sm-8">
                        <input id="Tenant_Id" type="text" class="form-control">
                        <input id="Tenant_Type" type="text" class="form-control" value="1">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="col-sm-2 layui-form-label">租户姓名：</label>
                    <div class="col-sm-4">
                        <input id="Tenant_Name" type="text" class="form-control" placeholder="请输入用户名" autofocus="autofocus" datacol="yes" err="租户姓名" checkexpession="NotNull">
                    </div>
                    <label class="col-sm-2 layui-form-label">
                        <nobr>租户性别：</nobr>
                    </label>
                    <div class="col-sm-4">
                        <select name="temp" class="form-control" id="Tenant_Sex">
                            <option value="1">男</option>
                            <option value="2">女</option>
                        </select>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="col-sm-2 layui-form-label">身份证号码：</label>
                    <div class="col-sm-4">
                        <input id="Tenant_IDNumber" type="text" class="form-control" placeholder="请输入身份证号码" autofocus="autofocus" datacol="yes" err="身份证号码" checkexpession="NotNull">
                    </div>
                    <label class="col-sm-2 layui-form-label">联系电话：</label>
                    <div class="col-sm-4">
                        <input id="Tenant_Phone" type="text" class="form-control" placeholder="请输入电话号码" autofocus="autofocus" datacol="yes" err="联系电话" checkexpession="MobileOrPhone">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="col-sm-2 layui-form-label">工作单位：</label>
                    <div class="col-sm-4">
                        <input id="Tenant_Company" type="text" class="form-control" placeholder="请输入工作单位" autofocus="autofocus" datacol="yes" err="工作单位" checkexpession="NotNull">
                    </div>
                    <label class="col-sm-2 layui-form-label">
                        <nobr>职业：</nobr>
                    </label>
                    <div class="col-sm-4">
                        <select name="temp" class="form-control" id="Tenant_Vocation">
                            <option value="1">无</option>
                            <option value="2">教师</option>
                            <option value="3">医生</option>
                        </select>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="col-sm-2 layui-form-label">入租人数：</label>
                    <div class="col-sm-4">
                        <input id="Tenant_Number" type="text" class="form-control" placeholder="请输入入租人数" autofocus="autofocus" datacol="yes" err="入租人数" checkexpession="Num">
                    </div>
                    <label class="col-sm-2 layui-form-label">
                        <nobr>人口性质：</nobr>
                    </label>
                    <div class="col-sm-4">
                        <select name="temp" class="form-control" id="Tenant_Nature">
                            <option value="1">无</option>
                            <option value="2">常住人口</option>
                            <option value="3">流动人口</option>
                            <option value="4">暂住人口</option>
                        </select>
                    </div>
                </div>

                <div class="layui-form-item" id="divNationality">
                    <label class="col-sm-2 layui-form-label">
                        <nobr>所属国籍：</nobr>
                    </label>
                    <div class="col-sm-4">
                        <select name="temp" class="form-control" id="Tenant_Nationality">
                            <option value="1">无</option>
                            <option value="2">中国</option>
                            <option value="3">美国</option>
                        </select>
                    </div>
                    <label class="col-sm-2 layui-form-label">管理代码：</label>
                    <div class="col-sm-4">
                        <input id="Tenant_Code" type="text" class="form-control" placeholder="请输入管理代码" autofocus="autofocus" datacol="yes" err="管理代码" checkexpession="NotNull">
                    </div>
                </div>

            </form>
            <div class="hr-line-dashed"></div>
            <div class="form-group">
                <div class="col-sm-11 ">
                    <button id="btnSure" class="btn btn-info pull-right">
                        <i class="fa fa-check"></i>提交
                    </button>
                </div>
            </div>
        </div>
    </div>
    <!--查询-->
    @using (Html.BeginForm("Zor_TenantPersonal", "Base", new RouteValueDictionary { { "Model", Model } }, FormMethod.Get))
    {
        <!-- 查询模态框 -->
    <div id="myModalSearch" hidden data-backdrop="static">
        <div id="divfrom" class="layui-tab-content">
            <div class="form-horizontal">
                <div class="layui-form-item">
                    <label class="col-sm-3 layui-form-label">租户姓名：</label>
                    <div class="col-sm-8">
                        <input type="text" class="form-control" name="Tenant_Name" value="@Model.Tenant_Name">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="col-sm-3 layui-form-label">身份证：</label>
                    <div class="col-sm-8">
                        <input type="text" class="form-control" name="Tenant_IDNumber" value="@Model.Tenant_IDNumber">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="col-sm-3 layui-form-label">性别：</label>
                    <div class="col-sm-8">
                        <select name="sex" class="form-control">
                            <option value="">全部</option>
                            <option value="@Model.sex">男</option>
                            <option value="@Model.sex">女</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="col-sm-3 layui-form-label">联系电话：</label>
                    <div class="col-sm-8">
                        <input type="text" class="form-control" name="Tenant_Phone" value="@Model.Tenant_Phone">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="col-sm-3 layui-form-label">管理代码：</label>
                    <div class="col-sm-8">
                        <input type="text" class="form-control" name="Tenant_Code" value="@Model.Tenant_Code">
                    </div>
                </div>
            </div>
            <div class="box-footer">
                <button type="submit" class="btn btn-info pull-right">
                    <i class="fa fa-search"></i>查询
                </button>
            </div>
        </div>
    </div>

    }

    <!-- 导出模态 -->
    <form action="/Base/ExportTenantPerson" enctype="multipart/form-data" method="post" id="formDownload">
        <div id="exportHtml" style="display:none;">
            <div class="eh_wrap">
                <div class="eh_head">
                    <p style="">请选择您要导出的数据列</p>
                </div>
                <table width="100%" cellpadding="5" cellspacing="0">
                    <tr>
                        <td><input id="Tenant_Name" type="checkbox" value="姓名" name="chk_list" checked="checked" /><label>姓名</label></td>
                        <td><input id="sex" type="checkbox" value="性别" name="chk_list" checked="checked" /><label>性别</label></td>
                        <td><input id="Tenant_IDNumber" type="checkbox" value="身份证" name="chk_list" checked="checked" /><label>身份证</label></td>
                        <td><input id="Tenant_Phone" type="checkbox" value="联系电话" name="chk_list" checked="checked" /><label>联系电话</label></td>
                    </tr>
                    <tr>
                        <td><input id="Tenant_Company" type="checkbox" value="工作单位" name="chk_list" checked="checked" /><label>工作单位</label></td>
                        <td><input id="Tenant_Number" type="checkbox" value="入租人数" name="chk_list" checked="checked" /><label>入租人数</label></td>
                        <td><input id="nature" type="checkbox" value="人口性质" name="chk_list" checked="checked" /><label>人口性质</label></td>
                        <td><input id="Tenant_Code" type="checkbox" value="管理代码" name="chk_list" checked="checked" /><label>管理代码</label></td>
                    </tr>
                </table>
            </div>
            <div class="box-footer">
                <button type="submit" id="btnExportSure" class="btn btn-info pull-right">
                    <i class="fa fa-repeat"></i>导出
                </button>
                <input type="hidden" id="fields" name="fields" value="" />
                <input type="hidden" id="where" name="where" value="and Tenant_Type=1" />
            </div>
        </div>
    </form>

    <!-- 详情模态 -->
    <div id="myModalDetails" hidden data-backdrop="static">
        <div id="divfrom" class="layui-tab-content">
            <form method="get" class="form-horizontal">
                <div class="layui-form-item">
                    <label class="col-sm-3 layui-form-label">租户姓名：</label>
                    <div class="col-sm-3 layui-input" id="Tenant_Names"></div>
                    <label class="col-sm-3 layui-form-label">租户性别：</label>
                    <div class="col-sm-3 layui-input" id="Tenant_Sexs"></div>
                </div>

                <div class="layui-form-item">
                    <label class="col-sm-3 layui-form-label f12">身份证号码：</label>
                    <div class="col-sm-3 layui-input" id="Tenant_IDNumbers"></div>
                    <label class="col-sm-3 layui-form-label">联系电话：</label>
                    <div class="col-sm-3 layui-input" id="Tenant_Phones"></div>
                </div>

                <div class="layui-form-item">
                    <label class="col-sm-3 layui-form-label">工作单位：</label>
                    <div class="col-sm-3 layui-input" id="Tenant_Companys"></div>
                    <label class="col-sm-3 layui-form-label">职业： </label>
                    <div class="col-sm-3 layui-input" id="Tenant_Vocations"></div>
                </div>

                <div class="layui-form-item">
                    <label class="col-sm-3 layui-form-label">入租人数：</label>
                    <div class="col-sm-3 layui-input" id="Tenant_Numbers"></div>
                    <label class="col-sm-3 layui-form-label">人口性质： </label>
                    <div class="col-sm-3 layui-input" id="Tenant_Natures"></div>
                </div>
                <div class="layui-form-item" id="divNationality">
                    <label class="col-sm-3 layui-form-label">所属国籍： </label>
                    <div class="col-sm-3 layui-input" id="Tenant_Nationalitys"></div>
                    <label class="col-sm-3 layui-form-label">管理代码：</label>
                    <div class="col-sm-3 layui-input" id="Tenant_Codes"></div>
                </div>

            </form>
        </div>
    </div>


    <script type="text/javascript">
        $(function () {

            /*刷新*/

            $("#btnRefresh").click(function () {
                Replace();
            });

            /*全选*/

            $("#cbkCheckAll").click(function () {
                if (this.checked) {
                    $("input[name='chk']").prop('checked', true);
                } else {
                    $("input[name='chk']").prop('checked', false);
                }
            });
            /*查询*/

            $("#btnSearchFull").click(function () {
                LayerOpen('500px', '350px', '查询', $('#myModalSearch'));
            });

            /*增加个人租户*/

            $("#btnAdd").click(function () {              
                LayerOpen('750px', '350px', '个人租户新增', $('#myModal'));
            });

            /*修改用户*/

            $("#btnUpdate").click(function () {
                var checkId = CheckboxValueIDs();
                $("#tenant_id").attr("disabled", "disabled");
                if (checkId.length == 0) {
                    layer.msg("请选择要修改的信息！");
                    return;
                }
                if (checkId.length > 1) {
                    layer.msg("仅可选择一行信息修改！");
                    return;
                }
                $("#Tenant_Id").val(checkId[0]);
                $("#Tenant_Name").val(getTableCell(2));
                $("#Tenant_IDNumber").val(getTableCell(4));
                $("#Tenant_Phone").val(getTableCell(5));
                $("#Tenant_Company").val(getTableCell(6));
                $("#Tenant_Number").val(getTableCell(7));
                $("#Tenant_Code").val(getTableCell(9));
                $("#Tenant_Sex").val(getTableCell(10));
                $("#Tenant_Nature").val(getTableCell(11));
                $("#Tenant_Nationality").val(getTableCell(12));
                $("#Tenant_IsTaxRegistration").val(getTableCell(13));
                $("#Tenant_Vocation").val(getTableCell(14));
                LayerOpen('750px', '350px', '个人租户修改', $('#myModal'));
            });

            /*删除租户*/

            $("#btnDelete").click(function () {
                var checkId = CheckboxValueIDs();
                if (checkId.length == 0) {
                    layer.msg("请选择要删除的租户！");                                                             //未选中任何行
                    return;
                }
                else {
                    layer.confirm("确定要删除吗?", { icon: 2, btn: ['确定', '取消'] }, function () {
                        ZorPostSimpleData("/Base/DeleteTenant", JSON.stringify({ 'Id': checkId }), function (data) { //获取数据(带参数)
                            layer.msg(data.AnswerMeg, function () {
                                layer.closeAll();
                                Replace();
                            });
                        })
                    })
                }
            });

            /*保存*/

            $("#btnSure").click(function () {

                if (!CheckDataValid('.form-horizontal')) {
                    return false;
                }
                if ($("#Tenant_Number").val() <= 0) {
                    layer.msg("入租人数必须大于0！");
                    return;
                }
                var JsData = GetWebControls(divfrom);
                ZorPostSimpleData("/Base/AddAlterTenant", JSON.stringify({ "tenant": JsData }), function (data) {
                    layer.msg(data.AnswerMeg, function () {
                        layer.closeAll();
                        Replace();
                    });
                });

            });

            /*导出*/

            $("#btnExport").click(function () {
                layer.open({
                    type: 1,
                    title: '导出提示',
                    shade: false,
                    skin: 'layui-layer-rim',
                    area: ['620px', '280px'], //宽高
                    content: $('#exportHtml')
                });
            });

            /*导出交互*/

            $("#btnExportSure").click(function () {
                var arr = new Array();
                $("[name='chk_list']").each(function () {
                    if ($(this).is(":checked")) {
                        arr.push($(this).attr("id") + "|" + $(this).val());
                    }
                });
                $("#fields").val(arr);
                document.getElementById('formDownload').submit();
                layer.closeAll();
            });

            /*详情*/

            $("#btnMessage").click(function () {
                var checkId = CheckboxValueIDs();
                $("#lbltitle").text("个人租户详情");
                if (checkId.length == 0) {
                    layer.msg("请选择要查看的信息！");
                    return;
                }
                if (checkId.length > 1) {
                    layer.msg("仅可选择一行信息查看！");
                    return;
                }
                LayerOpen('750px', '300px', '个人租户详情', $('#myModalDetails'));
                $("#Tenant_Names").html(getTableCell(2));
                $("#Tenant_IDNumbers").html(getTableCell(4));
                $("#Tenant_Phones").html(getTableCell(5));
                $("#Tenant_Companys").html(getTableCell(6));
                $("#Tenant_Numbers").html(getTableCell(7));
                $("#Tenant_Codes").html(getTableCell(9));
                $("#Tenant_Sexs").html(getTableCell(3));
                $("#Tenant_Natures").html(getTableCell(8));
                $("#Tenant_Nationalitys").html(getTableCell(15));
                $("#Tenant_IsTaxRegistrations").html(getTableCell(13));
                $("#Tenant_Vocations").html(getTableCell(16));
            });

        });
    </script>
</body>



</html>

